// InstalaSrv.cpp : Defines the entry point for the console application.
//

#include <windows.h>
#include <stdio.h>

#define NOME_DO_SERVICO "Scrabble"
#define CAMINHO "C:\\Scrabble\\Servidor.exe"

int main(int argc, char* argv[])
{
	SC_HANDLE schSCManager,schService;
	LPCTSTR lpszBinaryPathName = CAMINHO;
	schSCManager = OpenSCManager( 
		NULL,                    // local machine 
		NULL,                    // ServicesActive database 
		SC_MANAGER_ALL_ACCESS);  // full access rights 
 
	if (schSCManager == NULL) 
		printf("Erro: OpenSCManager\n"); 


    
 
    schService = CreateService( 
        schSCManager,              // SCManager database 
        NOME_DO_SERVICO,               // name of service 
        "Scrabble",           // service name to display 
        SERVICE_ALL_ACCESS,        // desired access 
        SERVICE_WIN32_OWN_PROCESS, // service type 
        SERVICE_DEMAND_START,      // start type 
        SERVICE_ERROR_NORMAL,      // error control type 
        lpszBinaryPathName,        // service's binary 
        NULL,                      // no load ordering group 
        NULL,                      // no tag identifier 
        NULL,                      // no dependencies 
        NULL,                      // LocalSystem account 
        NULL);                     // no password 
 
    if (schService == NULL) 
        printf("Error: CreateService\n"); 
    else 
        printf("CreateService SUCCESS.\n"); 
 
    CloseServiceHandle(schService); 
    CloseServiceHandle(schSCManager); 

 	return 0;
}

